<template>
	<view>
		<view class="">
			<button type="default" class="btn-list backOutDown" @click="READ_CALENDAR">获取日历</button>
		</view>
	</view>
</template>

<script>
	import {
		listionmsg,
		addCursor,
		getphone,
		callog
	} from '../../utils/permission/lib.js'
	import permision from "@/js_sdk/wa-permission/permission.js"
	export default {
		data() {
			return {
				platform: ''
			};
		},
		onLoad() {
			this.platform = uni.getSystemInfoSync().platform;
		},
		methods:{
			// Android验证是否实权 1已获取授权   0未获取授权   -1被永久拒绝授权
			async requestAndroidPermission(ID) {
				var permisionID = 'android.permission.' + ID;
				var result = await permision.requestAndroidPermission(permisionID);
				console.log('值',permisionID,result)
				if (result == -1) {
					// 打开设置
					permision.gotoAppPermissionSetting()
				}
				return result == 1 ? true : false
			},
			// ios 验证是否实权 1已获取授权   0未获取授权   -1被永久拒绝授权
			async judgeIosPermission() {
				let result = await permision.judgeIosPermission("location");
				if (result == -1) {
					// 打开设置
					permision.gotoAppPermissionSetting()
				}
				return result == 1 ? true : false
			},
			getStatus(result) {
				console.log('状态 1 0 -1', JSON.stringify(result))
				if (uni.getSystemInfoSync().platform == "ios") {
					let strStatus;
					if (result) {
						strStatus = "已获得授权"
					} else {
						strStatus = "未获得授权"
					}
					uni.showModal({
						content: strStatus,
						showCancel: false
					});
				} else {
					let strStatus;
					if (result == 1) {
						strStatus = "已获得授权"
					} else if (result == 0) {
						strStatus = "未获得授权"
					} else {
						strStatus = "被永久拒绝权限"
						permision.gotoAppPermissionSetting()
					}
					uni.showToast({
						title: strStatus,
						type: 'none'
					});
				}
			},
			// 日历读取权限
			READ_CALENDAR() {
				// #ifdef APP-PLUS
				this.requestAndroidPermission('READ_CALENDAR')
				// #endif
			},
			
		}
	}
</script>

<style lang="scss">

</style>
